package server;

import java.util.ArrayList;

//parser, ktory zwraca liste stringow, gdzie list.get(0) to polecenia, list.get(1) to pierwszy ciag znakow po poleceniu, a list.get(2) to reszta

public class Parser {
	private static ArrayList<String> list = new ArrayList<String>(); // serio?
	private static String tmp;
	
	public static ArrayList<String> parse(String s) {
		System.out.println("To parse: " + s);
		synchronized (list) {
			int counter = 0;
			list = new ArrayList<String>();
			tmp = "";
			for (int i = 0; i < s.length(); i++)
				if (s.charAt(i) == ' ' && counter < 2) {
					list.add(tmp);
					tmp = "";
					counter++;
				}
				else tmp += s.charAt(i);
			list.add(tmp); // serio?
			System.out.println("Parsed to: " + list.toString());
			return list;
		}
	}
}